//
//  LSSubjDetailCell.m
//  NineGroupProject
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 lushan. All rights reserved.
//

#import "LSSubjDetailCell.h"
#import "SubjectModel.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>
@implementation LSSubjDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createSubView];
    }
    return self;
}
- (void)createSubView{
    
    _relate_img = [[UIImageView alloc] init];
//    _relate_img.backgroundColor = [UIColor redColor];
    _relate_img.image = [UIImage imageNamed:@"placeholderImag"];
    [self.contentView addSubview:_relate_img];
    
    [_relate_img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.5);
        make.top.mas_equalTo(10);
        make.bottom.mas_equalTo(-10);
    }];
    
    
    _experience_title = [[UILabel alloc] init];
//    _experience_title.backgroundColor = [UIColor lightGrayColor];
    _experience_title.numberOfLines = 0;
    [self.contentView addSubview:_experience_title];
    
    [_experience_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_relate_img.mas_right).offset(10);
        make.right.mas_equalTo(-10);
        make.height.equalTo(_relate_img.mas_height).multipliedBy(0.5);
        make.top.mas_equalTo(10);
    }];
    
    _type_name = [[UILabel alloc] init];
//    _type_name.backgroundColor = [UIColor yellowColor];
    [_relate_img addSubview:_type_name];
    
    [_type_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_relate_img.mas_left).offset(5);
        make.bottom.equalTo(_relate_img.mas_bottom).offset(-5);
        make.width.equalTo(_relate_img.mas_width).multipliedBy(0.3);
        make.height.equalTo(_relate_img.mas_height).multipliedBy(0.2);
    }];
    
    
    _zone_name = [[UILabel alloc] init];
//    _zone_name.backgroundColor = [UIColor cyanColor];
    _zone_name.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_zone_name];
    
    [_zone_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_relate_img.mas_right).offset(10);
        make.top.equalTo(_experience_title.mas_bottom).offset(20);
        make.height.equalTo(_experience_title.mas_height).multipliedBy(0.3);
        make.width.equalTo(_experience_title.mas_width).multipliedBy(0.5);
    }];
    
    _theme_type_name = [[UILabel alloc] init];
//    _theme_type_name.backgroundColor = [UIColor orangeColor];
    _theme_type_name.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_theme_type_name];
    
    [_theme_type_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-10);
        make.left.equalTo(_relate_img.mas_right).offset(10);
        make.top.equalTo(_zone_name.mas_bottom).offset(5);
        make.width.equalTo(_experience_title.mas_width).multipliedBy(0.5);
    }];
    
}
- (void)setSubTVM:(SubjTVModel *)subTVM{
    if (_subTVM != subTVM) {
        _subTVM = subTVM;
    }
    NSURL *urls = [NSURL URLWithString:_subTVM.relate_img];
    [self.relate_img sd_setImageWithURL:urls placeholderImage:[UIImage imageNamed:@"placeholderImag.png"]];
    _experience_title.text = _subTVM.experience_title;
    _type_name.text = _subTVM.type_name;
    _zone_name.text = _subTVM.zone_name;
    _theme_type_name.text = _subTVM.theme_type_name;
}
@end
